//
//  LeaderTableViewCell.m
//  Doctor1.0
//
//  Created by mk on 15/7/13.
//  Copyright (c) 2015年 cocoa-mk. All rights reserved.
//

#import "LeaderTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "UIColor+AddColor.h"
@implementation LeaderTableViewCell

- (void)awakeFromNib
{
    // Initialization code
    
    imageAvatar.layer.cornerRadius = imageAvatar.width / 2 ;
    imageAvatar.clipsToBounds = YES;
    
    for (NSLayoutConstraint *constraints in [desc constraints])
    {
        if (constraints.firstItem == desc && constraints.firstAttribute == NSLayoutAttributeWidth)
        {
            constraints.constant = appScreenWidth-20;
            break;
        }
    }
    
    
    for (NSLayoutConstraint *constraints in [labGood constraints])
    {
        if (constraints.firstItem == labGood && constraints.firstAttribute == NSLayoutAttributeWidth)
        {
            constraints.constant = appScreenWidth-20;
            break;
        }
    }

    for (NSLayoutConstraint *constraints in [labHonour constraints])
    {
        if (constraints.firstItem == labHonour && constraints.firstAttribute == NSLayoutAttributeWidth)
        {
            constraints.constant = appScreenWidth-20;
            break;
        }
    }

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(void)fillDataWith:(TeamLeaderInfo *)leader noMember:(BOOL)no teamData:(NSMutableDictionary *)dic
{
    [imageAvatar sd_setImageWithURL:leader.leader_imageUrl placeholderImage:loadDoctorImageDefaule];
    
    name.text =  leader.leader_name;//医生名字
    hosName.text = leader.leader_hpName;//医院
    
    if (leader.leader_mTitle.length>0 && leader.leader_aTitle.length>0)
    {
      mTitle.text = [NSString stringWithFormat:@"%@|%@",leader.leader_mTitle,leader.leader_aTitle];//科室
    }else
    {
      mTitle.text = @"";
    }
    
    //专家荣誉
    NSString * strHonour = @"";
    for (int i = 0; i<leader.leader_honour.count; i++)
    {
        if([strHonour isEqualToString:@""]) strHonour = [NSString stringWithFormat:@"%d.%@",i+1,[leader.leader_honour objectAtIndex:i]];
        else strHonour = [NSString stringWithFormat:@"%@\n%d.%@",strHonour,i+1,[leader.leader_honour objectAtIndex:i]];
    }
    labHonour.text = [NSString stringWithFormat:@"%@",strHonour];//荣誉
    
    //科室
    if (leader.leader_hpDeptName.length)
    {
      [btnDepartment setBackgroundImage:[[UIImage imageNamed:@"leader_ke_bg.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:5] forState:UIControlStateNormal];
      [btnDepartment setTitle:leader.leader_hpDeptName forState:UIControlStateNormal];
    }
    else
    {
        [btnDepartment setBackgroundImage:[[UIImage imageNamed:@""] stretchableImageWithLeftCapWidth:6 topCapHeight:5] forState:UIControlStateNormal];
        [btnDepartment setTitle:@"" forState:UIControlStateNormal];
    }
    
    NSString * strdesc = NullObjToString([dic objectForKey:@"desc"]);
    desc.text =[NSString stringWithFormat:@"%@",strdesc];
  
    NSString * strgood = NullObjToString([dic objectForKey:@"goodAt"]);
    labGood.text = [NSString stringWithFormat:@"%@",strgood];
    
    //没有团队成员
  
    for (NSLayoutConstraint *constraints in [viewMember constraints])
    {
        if (constraints.firstItem == viewMember && constraints.firstAttribute == NSLayoutAttributeHeight)
        {
            constraints.constant = (no?0:70);
            break;
        }
    }
    
}

@end






